From e00498fcd8d5a006c0016bce6e2f77e5c78cfc82 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Fri, 14 Dec 2012 11:57:49 -0600 Subject: [PATCH] New signal populate-popup Instead of conditionally creating contextual menu items like 'Show file properties', we'll instead let the caller populate the popup menu, as is done for GtkEntry. Signed-off-by: Federico Mena Quintero --- gtk/gtkplacessidebar.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index a59da607e2..033fda0917 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -148,6 +148,9 @@ struct _GtkPlacesSidebarClass { void (* open_location) (GtkPlacesSidebar *sidebar, GFile *location, GtkPlacesOpenMode open_mode); + void (* populate_popup) (GtkPlacesSidebar *sidebar, + GtkMenu *menu, + GFile *selected_item); void (* show_file_properties) (GtkPlacesSidebar *sidebar, GFile *file); void (* empty_trash_requested) (GtkPlacesSidebar *sidebar); @@ -203,6 +206,7 @@ typedef enum { enum { OPEN_LOCATION, + POPULATE_POPUP, SHOW_FILE_PROPERTIES, EMPTY_TRASH_REQUESTED, SHOW_ERROR_MESSAGE, @@ -308,6 +312,13 @@ emit_open_location (GtkPlacesSidebar *sidebar, GFile *location, GtkPlacesOpenMod location, open_mode); } +static void +emit_populate_popup (GtkPlacesSidebar *sidebar, GtkMenu *menu, GFile *selected_item) +{ + g_signal_emit (sidebar, places_sidebar_signals[POPULATE_POPUP], 0, + menu, selected_item); +} + static void emit_show_file_properties (GtkPlacesSidebar *sidebar, GFile *file) { @@ -3704,6 +3715,17 @@ gtk_places_sidebar_class_init (GtkPlacesSidebarClass *class) G_TYPE_OBJECT, GTK_TYPE_PLACES_OPEN_MODE); + places_sidebar_signals [POPULATE_POPUP] = + g_signal_new (I_("populate-popup"), + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GtkPlacesSidebarClass, populate_popup), + NULL, NULL, + _gtk_marshal_VOID__OBJECT_OBJECT, + G_TYPE_NONE, 2, + G_TYPE_OBJECT, + G_TYPE_OBJECT); + places_sidebar_signals [SHOW_FILE_PROPERTIES] = g_signal_new (I_("show-file-properties"), G_OBJECT_CLASS_TYPE (gobject_class), -- 2.30.2